Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverse words #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

reverse words #22

wants to merge 2 commits into from

Conversation

kayxn23
Copy link

@kayxn23 kayxn23 commented Sep 18, 2018

No description provided.

last += 1
end
if first == last || last == my_words.length - 1
my_words[first..last] = string_reverse(my_words[first..last])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any comments on time and space complexity. As we saw in the first few slides of https://drive.google.com/file/d/0B__DV26QHsH4bWJmS1A0QXBad1U/view?usp=sharing because of using the substring method e.g. my_words[first..last], your space complexity will be O(n).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of a solution by updating your string_reverse method to take two additional parameters first and last along with the complete my_words and then only reversing the characters in my_words from index first to index last?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you've given it some thought, take a look at the solution at https://github.com/Ada-C10/reverse_words/blob/solution/lib/reverse_words.rb

@shrutivanw
Copy link

Nice work!

See some comments inline and slack me if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants